/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package suac.familia;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import suac.dependente.Dependente;

/**
 *
 * @author acer
 */
public class FamiliaTableModel extends AbstractTableModel {

    private String[] nomeColunas = {"Código", "Nome da Família", "Cidade", "Rua", "Número da Casa", "Ativa"};
    private List<Familia> familia;

    public FamiliaTableModel() {
        familia = new ArrayList<Familia>();
    }

    public FamiliaTableModel(List<Familia> lista) {
        this();
        this.familia.clear();
        this.familia.addAll(lista);
        super.fireTableDataChanged();

    }

    public int getRowCount() {
        return familia.size();
        //throw new UnsupportedOperationException("Not supported yet.");  
    }

    public int getColumnCount() {
        return nomeColunas.length;
        //throw new UnsupportedOperationException("Not supported yet.");  
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Familia familia = this.familia.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return familia.getIdFamilia();
            case 1:
                return familia.getNome_familia();
            case 2:
                return familia.getCidade();
            case 3:
                return familia.getRua();
            case 4:
                return familia.getNumerodacasa();
            case 5:
                if (familia.isFamiliaativa()) {
                    return "Sim";
                } else {
                    return "Não";
                }

        }
        return null;
        //throw new UnsupportedOperationException("Not supported yet.");  
    }

    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return nomeColunas[0];
            case 1:
                return nomeColunas[1];
            case 2:
                return nomeColunas[2];
            case 3:
                return nomeColunas[3];
            case 4:
                return nomeColunas[4];
            case 5:
                return nomeColunas[5];
        }
        return null;
    }
}
